/* GUI CONVERTED from glutrrp.p (converter v1.76) Tue May 13 01:33:39 2003 */
/* glutrrp.p - GENERAL LEDGER UNPOSTED TRANSACTION REGISTER                   */
/* Copyright 1986-2003 QAD Inc., Carpinteria, CA, USA.                        */
/* All rights reserved worldwide.  This is an unpublished work.               */
/* $Revision: 1.7.3.12 $                                                         */
/*V8:ConvertMode=FullGUIReport                                                */
/* REVISION: 5.0      LAST MODIFIED: 03/16/89   BY: JMS   *B066*              */
/*                                   10/06/89   by: jms   *B330*              */
/* REVISION: 6.0      LAST MODIFIED: 07/06/90   by: jms   *D034*              */
/*                                   02/20/91   by: jms   *D366*              */
/* REVISION: 7.0      LAST MODIFIED: 10/18/91   by: jjs   *F058*              */
/*                                   02/26/92   by: jms   *F231*              */
/*                                   08/15/94   by: pmf   *FQ15*              */
/*                                   09/03/94   by: srk   *FQ80*              */
/*                                   11/17/94   by: str   *FT77*              */
/*                                   12/11/96   by: bjl   *K01S*              */
/*                                   04/10/97   BY: *K0BF* E. Hughart         */
/* REVISION: 8.6      LAST MODIFIED: 10/16/97   by: bvm   *K11J*              */
/* REVISION: 8.6E     LAST MODIFIED: 02/23/98   BY: *L007* A. Rahane          */
/* REVISION: 8.6E     LAST MODIFIED: 10/04/98   BY: *J314* Alfred Tan         */
/* REVISION: 9.1      LAST MODIFIED: 09/20/99   BY: *N033* Brenda Milton      */
/* REVISION: 9.1      LAST MODIFIED: 09/29/99   BY: *N014* Jeff Wootton       */
/* REVISION: 9.1      LAST MODIFIED: 03/24/00 BY: *N08T* Annasaheb Rahane */
/* REVISION: 9.1      LAST MODIFIED: 06/26/00 BY: *N0DJ* Mudit Mehta      */
/* REVISION: 9.1      LAST MODIFIED: 08/14/00 BY: *N0L1* Mark Brown           */
/* REVISION: 9.1      LAST MODIFIED: 09/25/00 BY: *N0VY* BalbeerS Rajput  */
/* Old ECO marker removed, but no ECO header exists *F0PN*                    */
/* Revision: 1.7.3.9     BY: Ed van de Gevel       DATE: 07/04/02  ECO: *P0B4*  */
/* Revision: 1.7.3.11    BY: Pawel Grzybowski    DATE: 04/01/03  ECO: *P0PN*  */
/* $Revision: 1.7.3.12 $   BY: Narathip W.         DATE: 05/03/03  ECO: *P0R5*  */
/******************************************************************************/
/* All patch markers and commented out code have been removed from the source */
/* code below. For all future modifications to this file, any code which is   */
/* no longer required should be deleted and no in-line patch markers should   */
/* be added.  The ECO marker should only be included in the Revision History. */
/******************************************************************************/

/* DISPLAY TITLE */

/*GUI global preprocessor directive settings */
&GLOBAL-DEFINE PP_PGM_RP TRUE
&GLOBAL-DEFINE PP_ENV_GUI TRUE


/*GUI preprocessor directive settings */
&SCOPED-DEFINE PP_GUI_CONVERT_MODE REPORT

{mfdtitle.i "2+ "}
{cxcustom.i "HKGLTRRP.P"}

{gldydef.i new}

define variable ref               like glt_ref     no-undo.
define variable ref1              like glt_ref     no-undo.

define variable dt                like glt_date    no-undo.
define variable dt1               like glt_date    no-undo.

define variable effdt             like glt_effdate no-undo.
define variable effdt1            like glt_effdate no-undo.

define variable vouch              like glt_doc   LABEL "ƾ֤" no-undo.
define variable vouch1             like glt_doc   no-undo.

define variable btch              like glt_batch   no-undo.
define variable btch1              like glt_batch   no-undo.

define variable unb               like glt_unb label "Unbalanced Only" no-undo.
define variable unb_msg           as character format "x(5)" no-undo.
define variable drtot             as decimal       no-undo
                                  format ">>>,>>>,>>>,>>>,>>>.99cr".
define variable crtot             like drtot       no-undo.
define variable type              like glt_tr_type no-undo.

define variable dtype              like tr_type no-undo.
define variable dtype1              like tr_type no-undo.

DEFINE VARIABLE usr_name            LIKE usr_userid NO-UNDO.

define variable amt               like glt_amt     no-undo.
define variable unbflag           like mfc_logical no-undo.
define variable account           as character format "x(22)" label "Account"  no-undo.
define variable glname            like en_name     no-undo.
define variable entity            like gltr_entity no-undo.
define variable entity1           like gltr_entity no-undo.
define variable entity_flag       like mfc_logical no-undo.
define variable displayed_effdate as logical       no-undo.


{&GLUTRRP-P-TAG14}

/* GET NAME OF CURRENT ENTITY */
find en_mstr where en_entity = current_entity no-lock no-error.
if not available en_mstr then do:
   {pxmsg.i &MSGNUM=3059 &ERRORLEVEL=3} /* NO PRIMARY ENTITY DEFINED */

   if c-application-mode <> 'web' then
      pause.
   leave.
end.
else do:
   glname = en_name.
   release en_mstr.
end.
assign
   entity  = current_entity
   entity1 = entity.

/* SELECT FORM */
{&GLUTRRP-P-TAG15}

/*GUI preprocessor Frame A define */
&SCOPED-DEFINE PP_FRAME_NAME A

FORM /*GUI*/ 
   
 RECT-FRAME       AT ROW 1.4 COLUMN 1.25
 RECT-FRAME-LABEL AT ROW 1   COLUMN 3 NO-LABEL
 SKIP(.1)  /*GUI*/
   entity   colon 25    entity1 colon 50 label {t001.i}
   ref      colon 25    ref1    colon 50 label {t001.i}
   dt       colon 25    dt1     colon 50 label {t001.i}
   effdt    colon 25    effdt1  colon 50 label {t001.i}
   btch     colon 25    btch1   colon 50 label {t001.i}
   vouch    colon 25    vouch1  colon 50 label {t001.i}
   dtype    COLON 25    dtype1  COLON 50 LABEL {t001.i}
   type     colon 25 
   usr_name COLON 25
   unb      colon 25
 SKIP(.4)  /*GUI*/
with frame a side-labels attr-space width 80
    NO-BOX THREE-D /*GUI*/.

 DEFINE VARIABLE F-a-title AS CHARACTER.
 F-a-title = glname.
 RECT-FRAME-LABEL:SCREEN-VALUE in frame a = F-a-title.
 RECT-FRAME-LABEL:WIDTH-PIXELS in frame a =
  FONT-TABLE:GET-TEXT-WIDTH-PIXELS(
  RECT-FRAME-LABEL:SCREEN-VALUE in frame a + " ", RECT-FRAME-LABEL:FONT).
 RECT-FRAME:HEIGHT-PIXELS in frame a =
  FRAME a:HEIGHT-PIXELS - RECT-FRAME:Y in frame a - 2.
 RECT-FRAME:WIDTH-CHARS IN FRAME a = FRAME a:WIDTH-CHARS - .5. /*GUI*/

/*GUI preprocessor Frame A undefine */
&UNDEFINE PP_FRAME_NAME


{&GLUTRRP-P-TAG16}

/* SET EXTERNAL LABELS */
setFrameLabels(frame a:handle).

{&GLUTRRP-P-TAG7}

/* REPORT BLOCK */

{wbrp01.i}


/*GUI*/ {mfguirpa.i true "printer" 132 " " " " " "  }

/*GUI repeat : */
/*GUI*/ procedure p-enable-ui:

   if ref1 = hi_char then ref1 = "".
   if dt =  low_date then dt = ?.
   if dt1 = hi_date then dt1 = ?.
   if btch1 = hi_char then btch1 = "".
   if vouch1 = hi_char then vouch1 = "".
   if effdt = low_date then effdt = ?.
   if effdt1 = hi_date then effdt1 = ?.
   if entity1 = hi_char then entity1 = "".
   IF dtype1 = hi_char THEN dtype1 = "".
   {&GLUTRRP-P-TAG17}
   unb = no.

   if c-application-mode <> 'web' then
      {&GLUTRRP-P-TAG18}
      
run p-action-fields (input "display").
run p-action-fields (input "enable").
end procedure. /* p-enable-ui, replacement of Data-Entry GUI*/

/*GUI*/ procedure p-report-quote:


   {wbrp06.i &command = update &fields = "   entity entity1 ref ref1 dt dt1
        effdt effdt1 btch btch1 vouch vouch1 TYPE  dtype dtype1 usr_name unb" &frm = "a"}

   {&GLUTRRP-P-TAG19}
   if (c-application-mode <> 'web') or
      (c-application-mode = 'web' and
      (c-web-request begins 'data'))
   then do:

      /* CREATE BATCH INPUT STRING */
      bcdparm = "".
      {&GLUTRRP-P-TAG20}
      {mfquoter.i entity  }
      {mfquoter.i entity1 }
      {mfquoter.i ref     }
      {mfquoter.i ref1    }
      {mfquoter.i dt      }
      {mfquoter.i dt1     }
      {mfquoter.i effdt   }
      {mfquoter.i effdt1  }
      {mfquoter.i btch    }
      {mfquoter.i btch1   }
      {mfquoter.i vouch   }
      {mfquoter.i vouch1  }
      {mfquoter.i type    }
      {mfquoter.i dtype   }
      {mfquoter.i dtype1  }
      {mfquoter.i usr_name}
      {mfquoter.i unb     }
      {&GLUTRRP-P-TAG21}

      if ref1 = "" then ref1 = hi_char.
      if dt = ?  then dt = low_date.
      if dt1 = ? then dt1 = hi_date.
      if btch1 = "" then btch1 = hi_char.
      if vouch1 = "" then vouch1 = hi_char.
      if effdt = ? then effdt = low_date.
      if effdt1 = ? then effdt1 = hi_date.
      if entity1 = "" then entity1 = hi_char.
      if dtype1 = "" then dtype1 = hi_char.
      {&GLUTRRP-P-TAG22}

      assign
         crtot = 0
         drtot = 0.
      {&GLUTRRP-P-TAG23}

   end.

   /* OUTPUT DESTINATION SELECTION */
   
/*GUI*/ end procedure. /* p-report-quote */
/*GUI - Field Trigger Section */

/*GUI MFSELxxx removed*/
/*GUI*/ procedure p-report:
/*GUI*/   {gpprtrpa.i "printer" 132 " " " " " " " " }
/*GUI*/   mainloop: do on error undo, return error on endkey undo, return error:

   find en_mstr where en_entity = current_entity no-lock no-error.

   define buffer gltdet for glt_det.
   
   {mfphead.i}

   {&GLUTRRP-P-TAG24}
   for each glt_det where
      glt_ref >= ref and glt_ref <= ref1 and
      glt_date >= dt and glt_date <= dt1 and
      glt_effdate >= effdt and glt_effdate <= effdt1 and
      entry(1, glt_desc, " ") >= dtype AND ENTRY(1, glt_desc, " ") <= dtype1 AND
      /* ( ( glt_batch >= btch AND glt_batch <= btch1 ) or btch = "") */
      ( glt_batch >= btch AND glt_batch <= btch1 ) AND
      ( glt_doc >= vouch AND glt_doc <= vouch1 )
      no-lock use-index glt_ref
         break by glt_batch by glt_ref
      with width 140 no-attr-space frame f-a no-box:
      {&GLUTRRP-P-TAG25}

      {mfguichk.i } /*Replace mfrpchk*/ 
      /* SET EXTERNAL LABELS */
      setFrameLabels(frame f-a:handle).

      /* THIS ENTITY CHECK CANNOT BE IN THE FOR EACH SINCE */
      /* IF IT IS, ORACLE WILL IGNORE THE USE-INDEX PHRASE */
      if glt_entity < entity or glt_entity > entity1 then next.

      if type <> "" and substring(glt_ref, 1, 2) <> type then next.

      IF usr_name <> "" AND glt_userid <> usr_name THEN NEXT.

      if unb = yes and glt_unb = no then next.

      {&GLUTRRP-P-TAG26}
      if first-of(glt_ref) then do:
         {&GLUTRRP-P-TAG27}
         entity_flag = no.
         find first gltdet where
            gltdet.glt_ref = glt_det.glt_ref and
            (gltdet.glt_entity < entity or
             gltdet.glt_entity > entity1) no-lock no-error.
         if available gltdet then do:
            entity_flag = yes.
            next.
         end.
         {&GLUTRRP-P-TAG1}
         {&GLUTRRP-P-TAG28}
         display
            glt_det.glt_batch
            glt_det.glt_ref
            {&GLUTRRP-P-TAG29}
            glt_det.glt_date column-label "Entered!Eff Date"
            glt_det.glt_userid WITH STREAM-IO /*GUI*/ .

         assign
            unb_msg = ""
            unbflag = no
            /* INDICATE THAT EFFDATE HAS NOT BEEN DISPLAYED */
            displayed_effdate = no.
         {&GLUTRRP-P-TAG2}
      end.

      else do:
         if entity_flag = yes then next.
         {&GLUTRRP-P-TAG5}
         {&GLUTRRP-P-TAG30}
         display "" @ glt_det.glt_ref WITH STREAM-IO /*GUI*/ .
         {&GLUTRRP-P-TAG31}

         /* DISPLAY EFFECTIVE DATE STACKED UNDER ENTERED DATE, */
         /* ON 2ND LINE OF REF IF NO ERROR ON 1ST LINE OF REF. */
         if not displayed_effdate
         then do:
            display
               glt_det.glt_effdate @ glt_det.glt_date WITH STREAM-IO /*GUI*/ .
            displayed_effdate = yes.
         end.
         else
            display
               "" @ glt_det.glt_date WITH STREAM-IO /*GUI*/ .
         display
            "" @ glt_det.glt_userid WITH STREAM-IO /*GUI*/ .
         {&GLUTRRP-P-TAG6}
      end.
      {&GLUTRRP-P-TAG32}
      amt = glt_det.glt_amt.
      if glt_det.glt_curr <> base_curr
      then
         amt = glt_det.glt_curr_amt.
      find ac_mstr where ac_code = glt_det.glt_acc no-lock no-error.
      if not available ac_mstr then do:
         accumulate glt_det.glt_amt (total by glt_det.glt_ref).
         {&GLUTRRP-P-TAG10}
         if glt_det.glt_amt < 0
         then crtot = crtot - glt_det.glt_amt.
         else drtot = drtot + glt_det.glt_amt.
         {&GLUTRRP-P-TAG11}
      end.
      else
      if ac_type <> "S" and ac_type <> "M" then do:
         accumulate glt_det.glt_amt (total by glt_det.glt_ref).
         {&GLUTRRP-P-TAG12}
         if glt_det.glt_amt < 0
         then crtot = crtot - glt_det.glt_amt.
         else drtot = drtot + glt_det.glt_amt.
         {&GLUTRRP-P-TAG13}
      end.
      {glacct.i
         &acc=glt_det.glt_acc
         &sub=glt_det.glt_sub
         &cc=glt_det.glt_cc
         &acct=account}
      {&GLUTRRP-P-TAG3}
      display
         glt_det.glt_line
         account FORMAT "X(12)"
/*         glt_det.glt_project      */
         glt_det.glt_entity
         glt_det.glt_desc FORMAT "x(20)"
         amt
         glt_det.glt_curr
         /* glt_det.glt_dy_code*/
         glt_det.glt_addr
         glt_det.glt_doc WITH STREAM-IO /*GUI*/ .
      {&GLUTRRP-P-TAG4}
      /* SECOND LINE NEEDED WHEN AN ERROR. */
      /* ALSO DISPLAY EFFECTIVE DATE STACKED UNDER ENTERED DATE. */
      if glt_det.glt_error <> "" then do:
         down 1.
         if not displayed_effdate
         then do:
            {&GLUTRRP-P-TAG8}
            display
               glt_det.glt_effdate @ glt_det.glt_date WITH STREAM-IO /*GUI*/ .
            {&GLUTRRP-P-TAG9}
            displayed_effdate = yes.
         end.

         display glt_det.glt_error @ glt_det.glt_desc WITH STREAM-IO /*GUI*/ .
      end.

      if daybooks-in-use and glt_det.glt_dy_code > "" and
         (glt_det.glt_dy_num = "" or glt_det.glt_dy_num = ?)
      then do:
         down 1.
         display  "* " + getTermLabel("NO_DAYBOOK_ENTRY",19) + "# *"
            @ glt_det.glt_desc WITH STREAM-IO /*GUI*/ .
      end.

      if glt_det.glt_unb = yes then unbflag = yes.

      if last-of(glt_det.glt_ref) then do:

         /* DISPLAY EFFECTIVE DATE STACKED UNDER ENTERED DATE, */
         /* ON LAST LINE OF REF IF NOT ALREADY DISPLAYED.      */
         if not displayed_effdate
         then do:
            down 1.
            {&GLUTRRP-P-TAG8}
            display
               glt_det.glt_effdate @ glt_det.glt_date WITH STREAM-IO /*GUI*/ .
            {&GLUTRRP-P-TAG9}
            displayed_effdate = yes.
         end.

         if unbflag = yes then
            unb_msg = "*" + getTermLabel("UNBALANCED",3) + "*".
         underline amt.

         display
            accum total by glt_det.glt_ref glt_det.glt_amt @ amt
            base_curr @ glt_det.glt_curr
            unb_msg @ glt_det.glt_doc /* glt_det.glt_dy_code */ WITH STREAM-IO /*GUI*/ .
         down 1.
      end.

      {&GLUTRRP-P-TAG33}
      
/*GUI*/ {mfguichk.i } /*Replace mfrpchk*/

   end.

   /* PRINT DEBIT AND CREDIT TOTALS */

   {&GLUTRRP-P-TAG34}
   put skip(2)

      {gplblfmt.i
         &FUNC=getTermLabelRtColon(""DEBIT_TOTAL"",20)
         &CONCAT="'  '"
      }  at 25 drtot space(1) base_curr

      {gplblfmt.i
         &FUNC=getTermLabelRtColon(""CREDIT_TOTAL"",20)
         &CONCAT="'  '"
      } at 75 crtot space(1) base_curr.
      {&GLUTRRP-P-TAG35}

   /* REPORT TRAILER  */
   
/*GUI*/ {mfguitrl.i} /*Replace mfrtrail*/

        {mfreset.i}

/*GUI*/ {mfgrptrm.i} /*Report-to-Window*/

end.


{wbrp04.i &frame-spec = a}

/*GUI*/ end procedure. /*p-report*/
/*GUI*/ {mfguirpb.i &flds=" entity entity1 ref ref1 dt dt1 effdt effdt1 btch btch1 vouch vouch1 dtype dtype1 type usr_name unb "} /*Drive the Report*/
